# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Mika Havela <mika.havela@gmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=zziplib
pkgver=0.13.78
pkgrel=0
pkgdesc="Lightweight library to easily extract data from zip files"
url="https://github.com/gdraheim/zziplib"
arch="all"
license="LGPL-2.0-or-later OR MPL-1.1"
makedepends="
	bash
	cmake
	python3
	samurai
	zlib-dev
	"
checkdepends="zip"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-utils
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/gdraheim/zziplib/archive/refs/tags/v$pkgver.tar.gz"

# secfixes:
#   0.13.69-r2:
#     - CVE-2018-16548
#     - CVE-2018-17828

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DBUILD_TESTS="$(want_check && echo ON || echo OFF)" \
		-DMSVC_STATIC_RUNTIME=OFF \
		-DZZIPSDL=OFF \
		-DZZIPTEST="$(want_check && echo ON || echo OFF)" \
		-DZZIP_TESTCVE=OFF \
		-DZZIPWRAP=OFF
	cmake --build build
}

check() {
	cmake --build build --target check
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

utils() {
	pkgdesc="Utilities for the zziplib library"

	amove usr/bin
}

sha512sums="
e96771c310a1a9eb227027e8c2a495409c01dd273b483b3a04119d6a273cce7c88ba77c192fcde5e85d0a37c847a0df8e521f460d00920e62153400f0743ea78  zziplib-0.13.78.tar.gz
"
